import axios from "axios";
import { Toast } from "vant";

const request=axios.create({
    baseURL:'http://interview-api-t.itheima.net/h5/',
    timeout:5000
})

// 请求拦截 和响应拦截
request.interceptors.request.use(function (config){
    return config
},function (err){
    return Promise.reject(err)
})



request.interceptors.response.use(function (response){
    return response.data
},function (err){
    if(err.response){
        Toast.fail(err.response.data.message)
    }
    return Promise.reject(err)
})

export default request 
